/******************* 公共变量 *******************/
var userId = core.getUrlData('user_id');

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		bank: '',
		name: '',
		setCardNum: '',
		newPw: '',
		confirmPw: '',
		btnJudge: true
	},
	methods: {
		checkPw: function (event) {
			var $this = $(event.target),
				thisIndex = $this.parent().index(),
				thisVal = $this.val();
			if (thisIndex == 0) {
				if (thisVal == '') {
					core.layerHint('银行名称不可为空');
				}
			} else if (thisIndex == 1) {
				if (thisVal == '') {
					core.layerHint('持卡人姓名不可为空');
				}
			} else if (thisIndex == 2) {
				if (thisVal) {
					if (!thisVal.match(/^\d{6}$/)) {
						core.layerHint('请输入6位纯数字卡号');
					}
				} else {
					core.layerHint('输入卡号不可为空');
				}
			} else {
				if (thisVal) {
					if (thisVal.match(/^\d{6}$/)) {
						if (thisIndex == 3) {
							if (thisVal != this.confirmPw) {
								core.layerHint('两次输入的密码不一致，请重新输入');
							}
						} else if (thisIndex == 4) {
							if (thisVal != this.newPw) {
								core.layerHint('两次输入的密码不一致，请重新输入');
							}
						}
					} else {
						core.layerHint('请输入6位纯数字密码');
					}
				} else {
					core.layerHint('输入密码不可为空');
				}
			}
		},
		submit: function () {
			var _this = this;
			if (this.bank) {
				if (this.name) {
					if (this.setCardNum) {
						if (this.setCardNum.match(/^\d{6}$/)) {
							if (this.newPw) {
								if (this.newPw.match(/^\d{6}$/)) {
									if (this.confirmPw) {
										if (this.newPw.match(/^\d{6}$/)) {
											if (this.newPw == this.confirmPw) {
												if (this.btnJudge) {
													this.btnJudge = false;
													$.ajax({
														url: userForgetPwUrl,
														type: 'post',
														data: {
															user_id: userId,
															password: this.newPw,
															password1: this.confirmPw,
															bank_name: this.bank,
															z_name: this.name,
															tail_num: this.setCardNum
														},
														success: function(data) {
															console.log(data);
															setTimeout(function () {
																_this.btnJudge = true;
															}, 1000);
															if (data.result == 1) {
																core.hintBack(data.message);
															} else {
																core.layerHint(data.message);
															}
														}
													});
												}
											} else {
												core.layerHint('两次输入的密码不一致，请重新输入');
											}
										} else {
											core.layerHint('确认密码必须为6位纯数字');
										}
									} else {
										core.layerHint('确认密码不可为空');
									}
								} else {
									core.layerHint('新密码必须为6位纯数字');
								}
							} else {
								core.layerHint('新密码不可为空');
							}
						} else {
							core.layerHint('请输入6位纯数字卡号');
						}
					} else {
						core.layerHint('银行卡卡号不可为空');
					}
				} else {
					core.layerHint('持卡人姓名不可为空');
				}
			} else {
				core.layerHint('银行名称不可为空');
			}
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		
	},
	mounted: function () {
		common.bindBack();
	},
	updated: function () {
		
	}
});